package com.group3.controller;

import com.group3.pojo.*;
import com.group3.pojo.result.DropLessonNameResult;
import com.group3.pojo.result.LeaveDetailResult;
import com.group3.service.ListService;
import com.group3.utils.Result;
import com.group3.service.CommonService;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping(value = "/common")
@Api(tags = "总公共接口")
@CrossOrigin
public class CommonController {
    @Resource
    private CommonService commonService;
    @Resource
    private ListService listService;

    //登录
    @PostMapping(value = "/login")
    @ApiOperation(value = "登录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "用户名", required = true,
                    dataType = "String"),
            @ApiImplicitParam(name = "password", value = "密码", required = true,
                    dataType = "String"),
            @ApiImplicitParam(name = "type", value = "用户类型", required = true,
                    dataType = "String")
    })
    public Result login(@RequestBody Login login) {
        return commonService.login(login);
    }


//===========================下拉框查询=============================

    //查找院系（班级表departName字段去重），下拉框使用
    @GetMapping(value = "/selectDepartName")
    @ApiOperation(value = "查找院系")
//    @ApiImplicitParam(name = "departName", value = "院系名称", required = false,
//            dataType = "String")
    public Result<List<String>> selectDepartName() {

        return listService.selectDropDepartName();
    }

    //查找专业（班级表professionName字段去重），下拉框使用
    @GetMapping(value = "/selectProfessionName")
    @ApiOperation(value = "查找专业")
//    @ApiImplicitParam(name = "professionName", value = "专业名称", required = false,
//            dataType = "String")
    public Result<List<String>> selectProfessionName() {

        return listService.selectDropProfessionName();
    }

    //查找年级（班级表grade字段去重），下拉框使用
    @GetMapping(value = "/selectGrade")
    @ApiOperation(value = "查找年级")
//    @ApiImplicitParam(name = "grade", value = "年级", required = false,
//            dataType = "String")
    public Result<List<String>> selectDropGrade() {

        return listService.selectDropGrade();
    }

    //查找班级（班级表classId字段去重），下拉框使用
    @GetMapping("/selectClassId")
    @ApiOperation(value = "查找班级")
//    @ApiImplicitParam(name = "classId", value = "班级名称（ID）", required = false,
//            dataType = "String")
    public Result<List<String>> selectDropClassId() {

        return listService.selectDropClassId();
    }//


    //------------------------------老师------------------------------------------------------

    //查找课程（课程id、课程名），下拉框使用
    @GetMapping(value = "/selectLessons")
    @ApiOperation(value = "查找课程（课程名）")
//    @ApiImplicitParam(name = "teacherId", value = "教师id", required = false,
//            dataType = "String")
    public Result<List<DropLessonNameResult>> selectLessons() {
        //todo 小米：是否根据老师id只查询该老师所教课程
        // 黄渝：否！可以考虑，但没必要

        return listService.selectLessons();
    }

    //老师-作业管理-下发作业：根据项目名查找小组，下拉框使用
    @GetMapping("/selectGroup")
//    @ApiOperation(value = "根据项目名查找小组")
    @ApiOperation(value = "查找小组")
//    @ApiImplicitParam(name = "lessonName", value = "小组名称", required = false,
//            dataType = "String")
    public Result<List<DropGroup>> selectGroup() {

        return listService.selectGroup();
    }

    //根据小组id查找学生，下拉框使用
    @GetMapping("/selectStudentByGroup")
    @ApiOperation(value = "根据小组id查找学生")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "groupId", value = "小组id", required = true,
                    dataType = "Integer")
    })
    public Result<List<DropStudent>> selectStudentByGroup(Integer groupId) {

        return listService.selectStudentByGroup(groupId);
    }

    //根据课程id查找学生，下拉框使用
    @GetMapping("/selectStudentByLesson")
    @ApiOperation(value = "根据课程id查找学生")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "lessonId", value = "课程id", required = true,
                    dataType = "Integer")
    })
    public Result<List<DropStudent>> selectStudentByLesson(Integer lessonId) {

        return listService.selectStudentByLesson(lessonId);
    }

    //查找责任教师（工号、姓名），下拉框使用
    @GetMapping(value = "/selectTeacherZ")
    @ApiOperation(value = "查找责任教师（工号、姓名）")
    public Result<List<DropTeacherName>> selectTeacherZ() {

        return listService.selectTeacherZ();
    }

    //查找实训教师（工号、姓名），下拉框使用
    @GetMapping("/selectTeacherS")
    @ApiOperation(value = "查找实训教师（工号、姓名）")
    public Result<List<DropTeacherName>> selectTeacherS() {

        return listService.selectTeacherS();
    }

    //查找班主任（工号、姓名），下拉框使用
    @GetMapping("/selectTeacherB")
    @ApiOperation(value = "查找班主任（工号、姓名）")
    public Result<List<DropTeacherName>> selectTeacherB() {

        return listService.selectTeacherB();
    }


    //===========================请假原因详情=============================

//    //查看请假原因详情（请假记录id）
//    @ApiOperation(value = "查看请假原因详情")
//    @GetMapping("/showLeave")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "leaveId", value = "请假记录id", required = true,
//                    dataType = "int")
//    })
//    public Result<LeaveDetailResult> showLeave() {
//
//        Result result = null;
//
//        return result;
//    }


//===========================门禁打卡记录=============================
//
//    //查询门禁打卡记录
//    @ApiOperation(value = "查询门禁打卡记录")
//    @GetMapping(value = "/Punch")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "date", value = "日期",
//                    dataType = "String"),
//            @ApiImplicitParam(name = "studentId", value = "学号",//(精确匹配）
//                    dataType = "String"),
//            @ApiImplicitParam(name = "studentName", value = "学员名称",//(模糊查询）
//                    dataType = "String"),
//    })
//    public Result<List<LeaveDetailResult>> selectPunch(@RequestBody Page page) {
//
//        Result result = null;
//
//        return result;
//    }


    //===========================根据附件地址删除附件=============================
    @ApiOperation(value = "删除附件")
    @DeleteMapping(value = "/deleteFile")
    @ApiImplicitParam(name = "fileUrl", value = "附件地址", required = true,
            dataType = "String")

    public Result deleteFile(String fileUrl) {

        Result result = null;

        return result;
    }

}
